package light.head.dao.site;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import light.head.constant.Parm;
import light.head.enm.RESULT;
import light.head.framework.base.BaseDAO;
import light.head.framework.entity.PageBean;
import light.head.model.ParkRecruit;
import org.springframework.stereotype.Service;
/**
 * 	园区招聘
 */
@Service
public class ParkRecruitDAO extends BaseDAO<ParkRecruit, Serializable>{
	private static final String sql_indexlist = "FROM ParkRecruit pr WHERE pr.deleted = 0 AND pr.status = 1 ORDER BY pr.sort";
	public RESULT findByMap(Map<String, String> map, PageBean pageBean) {
		StringBuffer hql = new StringBuffer("FROM ParkRecruit pr WHERE 1 = 1");
		List<Object> list = null;
		if (map != null) {
			list = new ArrayList<Object>();
			String post = map.get(Parm.POST);
			String name = map.get(Parm.NAME);
			String sort = map.get(Parm.SORT);
			String deleted = map.get(Parm.DELETED);
			String status = map.get(Parm.STATUS);
			if (post != "" && isNotNull(post)) {
				hql.append(" AND pr.post LIKE ? ");
				list.add("%" + post + "%");
			}
			if(status!=""&&isNotNull(status)){
				hql.append(" AND pr.status = ? ");
				list.add(Byte.parseByte(status));
			}
			if (name != "" && isNotNull(name)) {
				hql.append(" AND pr.name LIKE ? ");
				list.add("%" + name + "%");
			}
			if (sort != "" && isNotNull(sort)) {
				hql.append(" AND pr.sort = ? ");
				list.add(Integer.parseInt(sort));
			}
			if(deleted!=""&&isNotNull(deleted)){
				hql.append(" AND pr.deleted = ?");
				list.add(Boolean.parseBoolean(deleted));
			}
		}
		hql.append(" ORDER BY pr.sort");

		return findToPageBean(hql.toString(), pageBean, list);
	}
	
	public List<ParkRecruit> findList(){
		return super.find("FROM ParkRecruit pr WHERE pr.deleted = 0 ORDER BY pr.sort");
	}
	
	//获取首页List
	public List<ParkRecruit> getIndexList(){
		return super.find(sql_indexlist);
	}
}
